#pragma unmanaged

#include <BWSAL\InformationManager.h>

#pragma managed

#include "BorderManager.h"

#include "InformationManager.h"
#include "..\Util.h"

namespace BroodWar
{
	namespace Addon
	{
		BorderManager::BorderManager(BWSAL::BorderManager* manager)
		{
			instance = manager;
		}

		BorderManager::~BorderManager()
		{
			BWSAL::BorderManager::destroy();
		}

		BorderManager::!BorderManager()
		{
			BWSAL::BorderManager::destroy();
		}

		void BorderManager::Create(IInformationManager^ informationManager)
		{
			InformationManager^ manager = DirectCast<InformationManager^>(informationManager);
			BWSAL::BorderManager::destroy();
			s_instance = gcnew BorderManager(BWSAL::BorderManager::create(manager->instance));
		}

		BorderManager^ BorderManager::Instance::get()
		{
			return s_instance;
		}

		void BorderManager::OnFrame()
		{
			instance->onFrame();
		}
		
		void BorderManager::AddMyBase(BaseLocation^ location)
		{
			instance->addMyBase(ConvertBaseLocation(location));
		}
		
		void BorderManager::RemoveMyBase(BaseLocation^ location)
		{
			instance->removeMyBase(ConvertBaseLocation(location));
		}
		
		HashSet<Chokepoint^>^ BorderManager::MyBorder::get()
		{
			return ToHashSet<BWTA::Chokepoint*, Chokepoint^>(instance->getMyBorder(), &ConvertChokepoint);
		}
		
		HashSet<Chokepoint^>^ BorderManager::EnemyBorder::get()
		{
			return ToHashSet<BWTA::Chokepoint*, Chokepoint^>(instance->getEnemyBorder(), &ConvertChokepoint);
		}
		
		HashSet<Chokepoint^>^ BorderManager::MyRegions::get()
		{
			throw gcnew System::NotSupportedException("Not implemented in BWSAL");
		}
		
		HashSet<Chokepoint^>^ BorderManager::EnemyRegions::get()
		{
			throw gcnew System::NotSupportedException("Not implemented in BWSAL");
		}
		
		void BorderManager::Draw()
		{
			instance->draw();
		}
	}
}
